<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:h="http://java.sun.com/jsf/html"
	  xmlns:f="http://java.sun.com/jsf/core"	
	  xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:cc="http://java.sun.com/jsf/composite">
  <cc:interface>
      <cc:attribute name="bean"/>
      <cc:attribute name="outcome"/>
  </cc:interface>
  <cc:implementation>
	<p:dataTable id="tabela" var="objeto" value="#{cc.attrs.bean.lista}">
  		<cc:insertChildren/>
  		<p:column style="width:20px" >
			<h:link outcome="#{cc.attrs.outcome}editar.faces?id=#{objeto.id}">
		    	<h:graphicImage value="#{resource['img:editar.png']}" style="border: 0px;"/>
		    </h:link>	
		</p:column>        	
		<p:column style="width:20px" >        	
		    <h:commandLink action="#{cc.attrs.bean.remover}" onclick="return confirm('Confirma remoção do item selecionado?');" >
		    	<h:graphicImage value="#{resource['img:remover.png']}" style="border: 0px;"/>
		        <f:setPropertyActionListener value="#{objeto}" target="#{cc.attrs.bean.objeto}"/>
		    </h:commandLink>
        </p:column>  		
	</p:dataTable>
	<h:panelGrid columns="5">
		<p:commandButton id="primeiro" process="formListar" update="grade:tabela,grade:primeiro,grade:anterior,grade:proximo,grade:ultimo,grade:paginas" ajax="true" action="#{cc.attrs.bean.primeira}" image="ui-icon ui-icon-seek-first" disabled="#{cc.attrs.bean.primeiroRegistro == 0}"/>
		<p:commandButton id="anterior" process="formListar" update="grade:tabela,grade:primeiro,grade:anterior,grade:proximo,grade:ultimo,grade:paginas" ajax="true" action="#{cc.attrs.bean.anterior}" image="ui-icon ui-icon-seek-prev" disabled="#{cc.attrs.bean.primeiroRegistro == 0}"/>
		<p:commandButton id="proximo" process="formListar" update="grade:tabela,grade:primeiro,grade:anterior,grade:proximo,grade:ultimo,grade:paginas" ajax="true" action="#{cc.attrs.bean.proxima}" image="ui-icon ui-icon-seek-next" disabled="#{cc.attrs.bean.primeiroRegistro + cc.attrs.bean.registrosPorPagina >= cc.attrs.bean.totalRegistros}"/>
		<p:commandButton id="ultimo" process="grade:tabela,grade:primeiro,grade:anterior,grade:proximo,grade:ultimo,grade:paginas" ajax="true" action="#{cc.attrs.bean.ultima}" image="ui-icon ui-icon-seek-end" disabled="#{cc.attrs.bean.primeiroRegistro + cc.attrs.bean.registrosPorPagina >= cc.attrs.bean.totalRegistros}"/>
		<h:outputText id="paginas" value="Página #{cc.attrs.bean.paginaCorrente} / #{cc.attrs.bean.totalPaginas}"/>
	</h:panelGrid>
  </cc:implementation>
</html>